package com.spzx.product.controller;

import com.spzx.common.core.domain.R;
import com.spzx.common.security.annotation.InnerAuth;
import com.spzx.product.service.ProductSkuService;
import com.spzx.product.api.vo.ProductSkuVo;
import com.spzx.product.vo.SkuPriceVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.spzx.common.core.web.controller.BaseController;

import java.util.List;

/**
 * <p>
 * 商品sku 前端控制器
 * </p>
 *
 * @author spzx
 * @since 2024-12-19
 */
@Tag(name = "商品sku管理")
@RestController
@RequestMapping("/productSku")
public class ProductSkuController extends BaseController {

    @Autowired
    private ProductSkuService productSkuService;

/*    @Autowired
    private RemoteProductService remoteProductService;*/

    /**
     * 远程调用商品详情
     * 根据商品id查询商品详情
     *
     * @param skuId
     * @return
     */
    @InnerAuth
    @Operation(summary = "根据商品id查询商品详情")
    @GetMapping("/getProductSku/{skuId}")
    public R<ProductSkuVo> getProductSkuVoById(
            @Parameter(name = "skuId", description = "商品skuId")
            @PathVariable("skuId") Long skuId) {
        ProductSkuVo productSkuVo = productSkuService.getProductSkuVoById(skuId);
        return R.ok(productSkuVo);
    }

    @InnerAuth
    @Operation(summary = "获取商品sku最新价格信息")
    @GetMapping(value = "/getSkuPrice/{skuId}")
    public R<SkuPriceVo> getSkuPrice(
            @Parameter(name = "skuId", description = "商品skuId")
            @PathVariable("skuId") Long skuId) {
        SkuPriceVo skuPriceVo = productSkuService.getSkuPrice(skuId);
        return R.ok(skuPriceVo);
    }

    @InnerAuth
    @Operation(summary = "获取商品sku最新价格信息List")
    @PostMapping(value = "/getSkuPriceList")
    public R<List<SkuPriceVo>> getSkuPriceList(
            @RequestBody List<Long> skuIdList) {
        List<SkuPriceVo> skuPriceVoList = productSkuService.getSkuPriceList(skuIdList);
        return R.ok(skuPriceVoList);
    }
}
